<!DOCTYPE html>
<html>
<head lang="zh-cn">
    <link href="$!{__beat.server.contextPath}/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="$!{__beat.server.contextPath}/bootstrap/datepicker/datepicker3.css" rel="stylesheet">
    <link rel="stylesheet" href="$!{__beat.server.contextPath}/bootstrap/css/App.css" type="text/css" />
<style type="text/css">
        .table-center{
            text-align:center;
        }
        .table-center>tbody>tr>td{
            padding: 3px 10px;
        }
</style>
    <meta charset="UTF-8">
    <title>流量数据看板</title>
</head>
<body>


<div class="container-fluid">

        <div class="row" align="center" style="margin-bottom:8px; margin-top:5px;">
                    <form class="form-inline" action="$!{__beat.server.contextPath}/netflow/test" method="post">
                            <div class="form-group" style="width:180px">
                                <label for="businessName" style="padding-left:15px;">业务线：</label>
                                <select id="businessName" name="businessName" class="form-control input-sm" style="align:center; width:100px; ">
                                   #foreach($buss in $businessList)
                                   #set($i = $velocityCount - 1)
                                        <option value="$buss" #if("$buss" == $!businessName) selected #end>$business_CN_Map.get("$buss")</option>
                                    #end  
                                </select>
                            </div>  
                            <div class="form-group">                       
                                   <input type="submit" value="查询" class="btn btn-primary btn-xs"> 
                            </div>
                    </form>
        </div>

#if($!{businessName} != 'total')
    <div class="panel panel-default">
        <div class="panel-heading">$!{businessName_CN}三端流量占比($!{businessName_CN} / 总体)</div>
        <div class="panel-body" style="height: 450px">
            <div id='platRateOption' dateGrp='stat_date' indexType='pv'>
                <form class="form-inline">
                    <div  class="input-group input-group-sm" style="width: 20%;float: left">
                        <span class="input-group-addon">
                            <input id="time_checkbox_platRate" type="checkbox">
                        </span>
                        <input id="time_input_platRate" type="text" class="form-control time" placeholder="添加对比" disabled>
                    </div>
                    <div class="input-group input-group-sm btn-tab" style="margin-left: 26.5%">
                            <select id="index_platRate" class="form-control">
                            <option value="pv">PV</option>
                            <option value="uv">UV</option>
                            <option value="vppv">VPPV</option>
                            <option value="lide_pv">lide-pv</option>
                            <option value="lide_uv">lide-uv</option>
                        </select>
                    </div>                
                    <div class="btn-group btn-group-sm btn-tab" role="group" aria-label="Basic example"  style="float: right">
                        <button type="button" class="btn btn-default active btnPlatRate" dateGrp='stat_date'>日</button>
                        <button type="button" class="btn btn-default btnPlatRate" dateGrp='week_begin'>周</button>
                        <button type="button" class="btn btn-default btnPlatRate" dateGrp='month_num'>月</button>
                    </div>
                </form>
            </div>
            
            <div id="total_platRate" style="height:400px"></div>
        </div>
    </div>
#end


    <div class="panel panel-default">
        <div class="panel-heading">$!{businessName_CN}PC端流量二级来源数据</div>
        <div class="panel-body" style="height: 450px">
            <div id='sourceOption_pc2' dateGrp='stat_date' indexType='uv'>
                <form class="form-inline">
                    <div  class="form-group input-group input-group-sm" style="width: 20%;float: left">
                        <span class="input-group-addon">
                            <input id="time_checkbox_pc2" type="checkbox">
                        </span>
                        <input id="time_input_pc2" type="text" class="form-control  input-sm" placeholder="添加对比"  disabled>
                    </div>

                    <div class="form-group" style="width:230px;margin-left: 16.5%">
                        <label for="source1_name_pc" style="padding-left:15px;">一级来源：</label>
                        <select id="source1_name_pc" class="form-control input-sm" style="align:center; width:120px; ">
                                 <option value="广告系列">广告系列</option>
                                 <option value="SEO">SEO</option>
                        </select>
                    </div>    

                    <div class="form-group" >
                        <select id="index_source_pc2" class="form-control input-sm" style="align:center; width:100px;" >
                            <option value="pv">PV</option>
                            <option value="uv" selected>UV</option>
                            <option value="vppv">VPPV</option>
                            <option value="lide_pv">lide-pv</option>
                            <option value="lide_uv">lide-uv</option>
                            <option value="pvDIVuv">pv/uv</option>
                            <option value="vppvDIVuv">vppv/uv</option>
                        </select>
                    </div>                
                    <div class="btn-group btn-group-sm btn-tab" role="group" aria-label="Basic example"  style="float: right">
                        <button type="button" class="btn btn-default active btnSource_pc2" dateGrp='stat_date'>日</button>
                        <button type="button" class="btn btn-default btnSource_pc2" dateGrp='week_begin'>周</button>
                        <button type="button" class="btn btn-default btnSource_pc2" dateGrp='month_num'>月</button>
                    </div>
                </form>               
            </div>
            
            <div id="total_source_pc2" style="height:400px"></div>
        </div>
    </div>

  

    <div class="panel panel-default">
        <div class="panel-heading">$!{businessName_CN}M端流量二级来源数据</div>
        <div class="panel-body" style="height: 450px">
            <div id='sourceOption_m2' dateGrp='stat_date' indexType='uv'>
                <form class="form-inline">
                    <div  class="form-group input-group input-group-sm" style="width: 20%;float: left">
                        <span class="input-group-addon">
                            <input id="time_checkbox_m2" type="checkbox">
                        </span>
                        <input id="time_input_m2" type="text" class="form-control input-sm" placeholder="添加对比"  disabled>
                    </div>

                    <div class="form-group" style="width:230px;margin-left: 16.5%">
                        <label for="source1_name_m" style="padding-left:15px;">一级来源：</label>
                        <select id="source1_name_m" class="form-control input-sm" style="align:center; width:120px; ">
                                 <option value="渠道">渠道</option>
                                 <option value="SEO">SEO</option>
                        </select>
                    </div>   

                    <div class="form-group">
                        <select id="index_source_m2" class="form-control input-sm"  style="align:center; width:100px;" >
                            <option value="pv">PV</option>
                            <option value="uv" selected>UV</option>
                            <option value="vppv">VPPV</option>
                            <option value="lide_pv">lide-pv</option>
                            <option value="lide_uv">lide-pv</option>
                            <option value="pvDIVuv">pv/uv</option>
                            <option value="vppvDIVuv">vppv/uv</option>
                        </select>
                    </div>                
                    <div class="btn-group btn-group-sm btn-tab" role="group" aria-label="Basic example"  style="float: right">
                        <button type="button" class="btn btn-default active btnSource_m2" dateGrp='stat_date'>日</button>
                        <button type="button" class="btn btn-default btnSource_m2" dateGrp='week_begin'>周</button>
                        <button type="button" class="btn btn-default btnSource_m2" dateGrp='month_num'>月</button>
                    </div>
                </form>               
            </div>
            
            <div id="total_source_m2" style="height:400px"></div>
        </div>
    </div>


    <div class="panel panel-default">
        <div class="panel-heading">$!{businessName_CN}M端流量三级来源数据</div>
        <div class="panel-body" style="height: 450px">
            <div id='sourceOption_m3' dateGrp='stat_date' indexType='uv'>
                <form class="form-inline">
                    <div  class="form-group input-group input-group-sm" style="width: 20%;float: left">
                        <span class="input-group-addon">
                            <input id="time_checkbox_m3" type="checkbox">
                        </span>
                        <input id="time_input_m3" type="text" class="form-control input-sm" placeholder="添加对比"  disabled>
                    </div>

                    <div class="form-group" style="width:230px;margin-left: 16.5%">
                        <label for="source2_name_m" style="padding-left:15px;">二级来源：</label>
                        <select id="source2_name_m" class="form-control input-sm" style="align:center; width:120px; ">
                                 <option value="付费浏览器">付费浏览器</option>
                                 <option value="联盟">联盟</option>
                                 <option value="付费其他">付费其他</option>
                        </select>
                    </div>

                    <div class="form-group" >
                        <select id="index_source_m3"  class="form-control input-sm"  style="align:center; width:100px;" >>
                            <option value="pv">PV</option>
                            <option value="uv" selected>UV</option>
                            <option value="vppv">VPPV</option>
                            <option value="lide_pv">lide-pv</option>
                            <option value="lide_uv">lide-pv</option>
                            <option value="pvDIVuv">pv/uv</option>
                            <option value="vppvDIVuv">vppv/uv</option>
                        </select>
                    </div>                
                    <div class="btn-group btn-group-sm btn-tab" role="group" aria-label="Basic example"  style="float: right">
                        <button type="button" class="btn btn-default active btnSource_m3" dateGrp='stat_date'>日</button>
                        <button type="button" class="btn btn-default btnSource_m3" dateGrp='week_begin'>周</button>
                        <button type="button" class="btn btn-default btnSource_m3" dateGrp='month_num'>月</button>
                    </div>
                </form>               
            </div>
            
            <div id="total_source_m3" style="height:400px"></div>
        </div>
    </div>


</div>
</body>
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
<script src="$!{__beat.server.contextPath}/bootstrap/js/libs/bootstrap.js"></script>
<script src="$!{__beat.server.contextPath}/bootstrap/datepicker/bootstrap-datepicker.js"></script>
<script src="$!{__beat.server.contextPath}/bootstrap/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
<script src="$!{__beat.server.contextPath}/echarts2/source/echarts.js"></script>
<script type="text/javascript">
    var cate = "$!{businessName}";
    var dayMap={1:"周一",2:"周二",3:"周三",4:"周四",5:"周五",6:"周六",0:"周日"};
	var datepicker_op={
        format: "yyyy-mm-dd",
        clearBtn: false,
        language: "zh-CN",
        autoclose: true,
        todayHighlight: true,
        minViewMode:0,
		orientation: "top left"
    };

	function getDate(yyyymmdd){
        if(yyyymmdd.length==8){
            return Date.parse(yyyymmdd.substr(0,4)+'/'+yyyymmdd.substr(4,2)+'/'+yyyymmdd.substr(6,2));
        }else if(yyyymmdd.length==6){
            return Date.parse(yyyymmdd.substr(0,4)+'/'+yyyymmdd.substr(4,2));
        }
    }

    //获取星期几 dayDate 的格式为 yyyy-MM-dd
    function getWeekDay(dayDate){
        var jsDate = new Date(Date.parse(dayDate.replace(/\-/g,'/')));
        var weekNumber = jsDate.getDay();
        return dayMap[weekNumber];
    }

    function setDatePicker(ec,dateGrp,input){
        if('week_begin'==dateGrp){
        }else if('month_num'==dateGrp){
            datepicker_op.minViewMode=1;
            datepicker_op.format='yyyy-mm';
        }else{
            datepicker_op.minViewMode=0;
            datepicker_op.format='yyyy-mm-dd';
        }
        input.datepicker('remove');
        input.datepicker(datepicker_op);
        //获取显示的日期数组
        var days_show=ec.getShowDays();
        var days_all=ec.getAllDays();
        //设置时间可选范围
        input.datepicker('setStartDate',new Date(getDate(days_all[0])));
        input.datepicker('setEndDate',new Date(getDate(days_all[days_all.length-days_show.length])));
    }

    function changeDateGrp(item){
        var dateGrpVal = $(item).attr('dateGrp');
        var curDiv = $(item).closest('div[dateGrp]');
        $(curDiv).attr('dateGrp',dateGrpVal);
    }

    function changeIndex(item){
        var indexVal = $(item).val();
        var curDiv = $(item).closest('div[dateGrp]');
        $(curDiv).attr('indexType',indexVal);
    }

    $('.btn-tab button').click(function(e){
        $(this).addClass('active');
        $(this).siblings('button').each(function(){
            $(this).removeClass('active');
        });
    });


    //格式化输出数字
    function format_number(n){
        var b=parseInt(n).toString(); 
        var len=b.length; 
        if(len<=3){return b;} 
        var r=len%3; 
        return r>0?b.slice(0,r)+","+b.slice(r,len).match(/\d{3}/g).join(","):b.slice(r,len).match(/\d{3}/g).join(","); 
    };

    // 路径配置
    require.config({paths: {echarts: "$!{__beat.server.contextPath}/echarts2/dist",dashboard: "$!{__beat.server.contextPath}/js/"}});
	
    var charts = [];


#if($!{businessName} != 'total')
    //三端流量 占总体三端流量比
    require(['dashboard/netflow_platformRate_v3'],function(platformRateEC){
        charts.push(platformRateEC);
        platformRateEC.show(cate,2);
    });
#end

    //pc二级来源数据
   require(['dashboard/netflow_source2_pc_v1'],function(sourceEC_pc2){
        charts.push(sourceEC_pc2);
        sourceEC_pc2.show(cate,2);
    });

    //m二级来源数据
   require(['dashboard/netflow_source2_m_v1'],function(sourceEC_m2){
        charts.push(sourceEC_m2);
        sourceEC_m2.show(cate,2);
    });

    //m三级来源数据
   require(['dashboard/netflow_source3_m_v2'],function(sourceEC_m3){
        charts.push(sourceEC_m3);
        sourceEC_m3.show(cate,2);
    });



    $(window).resize(function(){
        $.each(charts,function(i,n){
            n.echart.resize();
        });
    });

</script>
</html>